package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.DtsPermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class DtsPermissionServiceImpl implements DtsPermissionService {
    @Resource
    DtsPermissionMapper permissionMapper;
    @Override
    public Set<String> findByRoleIds(Integer[] roleIds) {
        List<DtsPermission> permissions = permissionMapper.selectList(new LambdaQueryWrapper<DtsPermission>().select(DtsPermission::getPermission).in(DtsPermission::getRoleId, roleIds).eq(DtsPermission::getDeleted, false));
        Set<String> perms = permissions.stream().map(DtsPermission::getPermission).collect(Collectors.toSet());
        return perms;
    }
}
